﻿using DG.Tweening;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace YFrameWork.RunTime
{
    /// <summary>
    /// UI打开动画改变整体大小
    /// </summary>
    public class UIOpenAnimScale : UIOpenAnimationBase
    {
        public Transform mTarget;
        public float mScaleY;
        public float mDelay;
        public UIOpenAnimScale(Transform target, float ScaleY = 1, float delay = 0.3f)
        {
            mTarget = target;
            mScaleY = ScaleY;
            mDelay = delay;
        }
        public override void Open()
        {
            mTarget.DOScale(0, 0);
            Tweener tw = mTarget.DOScale(mScaleY, mDelay);
        }
    }
    /// <summary>
    /// UI关闭动画改变整体大小
    /// </summary>
    public class UICloseAnimScale : UICloseAnimationBase
    {
        public Transform mTarget;
        public float mScaleY;
        public float mDelay;

        public UICloseAnimScale(Transform target, float ScaleY = 0, float delay = 0.3f)
        {
            mTarget = target;
            mScaleY = ScaleY;
            mDelay = delay;
        }
        public override void Close(Action action)
        {
            mTarget.DOScale(1, 0);
            Tweener tw = mTarget.DOScale(mScaleY, mDelay);
            tw.OnComplete(() => { action?.Invoke(); });
        }
    }
}